/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.equipo13.p7;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.antlr.runtime.ANTLRInputStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;

/**
 *
 * @author Guillermo Garcia Juanes, Jose Antonio Hernandez Gonzalez
 */
public class Procesador {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        try {
            String rs = "";
            FileInputStream fis = new FileInputStream(args[0]);
            ANTLRInputStream input = new ANTLRInputStream(fis);
            AnaYACCLexer lexer = new AnaYACCLexer(input);
            /*Token token = lexer.nextToken();
            while (token.getType() != Token.EOF) {
                //System.out.println("Token: " + token.toString());
                if (token.getChannel() != Token.HIDDEN_CHANNEL)
                    rs += token.getText() + "\n";
                token = lexer.nextToken();
            }     
            System.out.println(rs);*/
            CommonTokenStream tokens = new CommonTokenStream(lexer);
            AnaYACCParser parser = new AnaYACCParser(tokens);
            parser.entrada();
        } catch (RecognitionException ex) {
                Logger.getLogger(Procesador.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FileNotFoundException e) {
            System.err.println("Error al abrir el fichero.");
        } catch (IOException e) {
            System.err.println("Error al abrir el fichero.");
        }
    }
}
